<template>
  <div class="continue">
    <div class="left-panel">
      <div class="menu-list">
        <template v-for="(item,key) in types1">
          <div class="item" :class="typeActive === key?'active':''" @click="switchType(key)">
            <i class="iconfont" :class="item.icon"></i>
            <div class="text">{{ item.name }}</div>
          </div>
        </template>
      </div>
      <div class="flag">筛选</div>
      <div class="menu-list">
        <template v-for="(item,key) in types2">
          <div class="item" :class="typeActive === key?'active':''" @click="switchType(key)">
            <i class="iconfont" :class="item.icon"></i>
            <div class="text">{{ item.name }}</div>
          </div>
        </template>
      </div>
    </div>

    <!--引入文件组件-->
    <template v-if="types2.hasOwnProperty(typeActive)">
      <User v-if="typeActive === 'user'"/>
      <Types v-else-if="typeActive === 'type'"/>
      <Chat v-else-if="typeActive === 'chat'"/>
    </template>

    <div class="right-panel">
      <div class="head-wrapper">
        <div class="search-wrapper">
          <div class="input-wrapper">
            <input placeholder="搜索文件名/联系人/群聊名称"/>
            <i class="iconfont chat-search"></i>
          </div>
        </div>
        <div class="tools">
          <div class="menu-list">
            <i class="iconfont chat-pushpin"></i>
            <i class="iconfont chat-minus"></i>
            <i class="iconfont chat-border"></i>
            <i class="iconfont chat-close"></i>
          </div>
        </div>
      </div>
      <div class="file-content-wrapper">
        <div class="item">
          <div class="svg">
            <img src="@/assets/fileSvg/zip.svg">
          </div>
          <div class="info">
            <div class="head">
              <div class="name">随记.txt</div>
              <div class="date">2025-07-07</div>
            </div>
            <div class="footer">
              <div class="nickname">gangan|文件传输助手</div>
              <div class="size">12.3k</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import Types from '@/components/files/types.vue';
import User from '@/components/files/user.vue';
import Chat from '@/components/files/chat.vue';
import {useFiles} from '@/hooks/filesHooks/files.ts';

let {types2, types1, typeActive, switchType} = useFiles();

</script>

<style scoped lang="scss">

.continue {
  display: flex;
  width: 100%;
  height: 100%;
}

.left-panel {
  width: 150px;
  background: #eee;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #ccc;


  .menu-list {
    display: flex;
    flex-direction: column;

    .item {
      display: flex;
      padding: 8px 8px 8px 16px;
      width: 100%;
      cursor: pointer;
      font-size: 14px;
      line-height: 30px;

      .iconfont {
        font-size: 22px;
        margin-right: 8px;
      }
    }

    .item:hover {
      background: #e1e1e1;
    }

    .active {
      background: #ccc;
    }
  }

  .flag {
    font-size: 14px;
    padding: 8px 8px 8px 16px;
    color: #aaa;
    margin-top: 32px;
  }
}

.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #eee;

  .head-wrapper {
    height: 50px;
    background: #ddd;
    padding: 0 4px 0 20px;
    display: flex;
    justify-content: space-between;

    .search-wrapper {
      height: 50px;
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;

      .input-wrapper {
        width: 70%;
        height: 30px;
        padding: 4px;
        font-size: 12px;
        line-height: 22px;
        border-radius: 4px;
        background: #eee;
        display: flex;

        .iconfont {
          width: 40px;
          text-align: center;
          color: #aaa;
        }

        input {
          width: 100%;
          height: 100%;
          border: none;
          outline: none;
          background: none;
          line-height: 22px;
        }
      }

    }

    .tools {
      display: flex;
      flex-direction: column;
      padding: 4px;

      .menu-list {
        display: flex;
        column-gap: 8px;

        .iconfont {
          font-size: 12px;
          cursor: pointer;
        }
      }
    }
  }

  .file-content-wrapper {
    flex: 1;
    padding: 16px;
    gap: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;

    .item {
      width: 100%;
      padding-left: 16px;
      display: flex;

      .svg {
        width: 40px;
        margin-right: 12px;

        img {
          width: 100%;
        }
      }

      .info {
        display: flex;
        flex: 1;
        flex-direction: column;
        padding-bottom: 8px;
        border-bottom: 1px solid #ddd;

        .head {
          display: flex;
          justify-content: space-between;
          font-size: 14px;
          line-height: 24px;

          .date {
            font-size: 12px;
            color: #aaa;
          }
        }

        .footer {
          display: flex;
          justify-content: space-between;
          font-size: 12px;
          line-height: 16px;
          color: #aaa;
        }
      }
    }

  }
}
</style>